<?php

namespace app\admin\model\auth;

use think\Model;

class AdminLogModel extends Model
{
    protected $name = 'admin_log';
    protected $pk = 'id';
    protected $autoWriteTimestamp = 'int';
    protected $createTime = 'created_at';
    public function addLog($title,$type,$id,$name){
        $data = [
            'admin_id' => $id,
            'username' => $name,
            'url' => request()->controller() . '/' . request()->action(),
            'ip' => getRealIp(),
            'title' => $title,
            'data' => json_encode(request()->param()),
            'user_agent' => isset(request()->header()['user-agent']) ? request()->header()['user-agent'] : '',
            'type' => $type, // 1添加 2修改 3删除 4登录
            'created_at' => time(),
        ];
      $this->insert($data);
    }
}